package com.demo.controller;

import com.demo.entity.PartnerType;
import com.demo.model.JsonMessage;
import com.demo.service.PartnerTypeService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

@Controller
@RequestMapping("/user/partnertype")
public class PartnerTypeController {

    @Autowired
    private PartnerTypeService partnerTypeService;

    @PostMapping("delete")
    @ResponseBody
    public JsonMessage delete(String PartnerType)
    {
        JsonMessage message=new JsonMessage();
        partnerTypeService.Delete(PartnerType);
        return message;
    }
    @PostMapping("list")
    @ResponseBody
    public JsonMessage list(@RequestParam(defaultValue = "0")int pageIndex,
                            @RequestParam(defaultValue = "10")int pageSize)
    {
        JsonMessage message=new JsonMessage();
        PageInfo<PartnerType> page=partnerTypeService.list(pageIndex,pageSize);
        message.setData(page);
        return message;
    }
    @PostMapping("add")
    @ResponseBody
    public JsonMessage add(@RequestBody PartnerType partnerType)
    {
        JsonMessage message=new JsonMessage();
        partnerTypeService.Insert(partnerType);
        return message;
    }
}
